package com.wgworkshop.pems.entity;

import com.wgworkshop.pems.common.enums.GenderEnum;
import com.wgworkshop.pems.common.enums.StudentStatusEnum;
import com.wgworkshop.pems.entity.converter.GenderConverter;
import com.wgworkshop.pems.entity.converter.StudentStatusConverter;

import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import java.util.Date;

/**
 * 学生实体类。
 * Created by wlc on 2017/7/2.
 */
@Entity(name = "student")
public class StudentEntity extends AbstractBaseEntity {
    private String code;
    private String name;
    private String parent;
    private String phone;
    @Convert(converter = GenderConverter.class)
    private GenderEnum gender;
    @Temporal(TemporalType.DATE)
    private Date birthday;
    @Temporal(TemporalType.DATE)
    private Date startDate;
    @Convert(converter = StudentStatusConverter.class)
    private StudentStatusEnum status;
    private String comment;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getParent() {
        return parent;
    }

    public void setParent(String parent) {
        this.parent = parent;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public GenderEnum getGender() {
        return gender;
    }

    public void setGender(GenderEnum gender) {
        this.gender = gender;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public StudentStatusEnum getStatus() {
        return status;
    }

    public void setStatus(StudentStatusEnum status) {
        this.status = status;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    @Override
    public int hashCode() {
        return this.getId().hashCode();
    }

    @Override
    public boolean equals(Object another) {
        if (another == null) return false;
        if (!(another instanceof StudentEntity)) return false;

        Long anotherId = ((StudentEntity) another).getId();
        return anotherId != null && getId() != null && anotherId.equals(getId());
    }
}
